package com.hbue.springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hbue.springboot.pojo.DTO.TbHistoryDTO;
import com.hbue.springboot.pojo.TbAccount;
import com.hbue.springboot.pojo.TbCustomer;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface TbCustomerMapper extends BaseMapper<TbCustomer> {
    @Select("select * from tb_customer where cust_name = #{name}")
    @Results({
            @Result(column="cust_name", property="custName", javaType=String.class),
            @Result(column="cust_mobile", property="custMobile", javaType=String.class),
            @Result(column="cust_address", property="custAddress", javaType=String.class),
            @Result(column="cust_ticket", property="custTicket", javaType=Integer.class),
            @Result(column="cust_name", property="account", javaType=TbAccount.class,
            // 其他字段的映射...
            one = @One(select = "com.hbue.springboot.mapper.TbAccountMapper.selectAccountByName")) // 确保方法名和路径正确
    })
    public TbCustomer getCustomerByName(String name);

//    @Update("update tb_customer set cust_mobile = #{customerDTO.custMobile}")
//    int updateCustomer(TbCustomer customerDTO);

    @Select("select * from tb_customer where cust_name = #{name}")
    TbCustomer selectByName(String name);

    @Select("select cust_name from tb_customer where id = #{id}")
    String getCustomerName(Integer id);

    @Select("select cust_address from tb_customer where cust_name = #{name}")
    String getCustomerAddress(String name);
}
